import request from '@/utils/my-request'

export function login(data) {
    return request({
        url: '/api/users/login',
        method: 'post',
        data
    })
}

export function reg({ nickName, userName, userPassword }) {
    return request({
        url: '/api/users/reg',
        method: 'post',
        params: { nickName, userName, userPassword }
    })
}
export function get({ page, limit }) {
    return request({
        url: "/api/users/get",
        method: 'get',
        params: { page, limit }
    })
}
export function logout() {
    return request({
        url: '/api/users/logout',
        method: 'post'
    })
}
export function del(_id) {
    return request({
        url: `/api/users/del/${_id}`,
        method: 'delete',
    })
}
export function update({ _id, userName, userPassword, status, nickName }) {
    return request({
        url: `/api/users/update/${_id}`,
        method: 'put',
        params: { userName, userPassword, status, nickName }
    })
}
export function search(find) {
    return request({
        url: `/api/users/search`,
        method: 'get',
        params: find
    })
}
export function delImg({ _id, url }) {
    return request({
        url: `/resource/users/${_id}`,
        method: 'patch',
        params: { url }
    })
}